Skip to content

python-sdk: make ruff skip generated members - #95

Merged
eunomie merged 2 commits into
mainfrom
implementer-fa8b45df
Nov 17, 2026
Merged

eunomie merged 2 commits into
mainfrom
implementer-fa8b45df

Conversation

@eunomie

@eunomie eunomie commented Nov 17, 2026

Copy link
Copy Markdown
Member

Generation now writes a standalone ruff.toml into each generated member: sdk/ (including sdk/entrypoint), clients/core and every clients/<name>. It goes through replaced() in scope.dang:

# Rewritten on every generation: do not edit.
extend-exclude = ["*"]

Ruff uses the closest config and does not inherit it, so ruff check . and ruff format . from the module root skip generated code and still check the author's code.

The file goes in the members, not the module root. The SDK never writes the module root, so an author's own root ruff.toml or pyproject.toml [tool.ruff] stays untouched and keeps working. A [tool.ruff] in the vendored sdk/pyproject.toml loses to sdk/ruff.toml.

Tests

  • New e2e assertions:
    • The shared scope-tree check, which every scope-generating check runs, asserts the generated ruff.toml files.
    • The init check asserts that generate leaves a user's root ruff.toml unchanged.
    • The clients check asserts the file in each client member.
  • New generated-ruff-skip-check, registered in engine-e2e. It runs ruff check --show-files . from the module root with the ruff pinned in sdk/uv.lock. It asserts that no listed path is under sdk/ or clients/, and that src/ is listed.
  • Passed on engine v1.0.0-beta.27:
    • generated-ruff-skip-check
    • generate-scope-init-check
    • generate-scope-clients-check
    • runtime-call-check
    • generate-scope-existing-check (first revision of the series only)
  • The engine-e2e checks, including floor-coverage-check, were not run locally; CI runs them.

Manual check on a generated default module with ruff 0.17.5 (earlier revision of the series, same behavior):

$ find . -name ruff.toml
./clients/core/ruff.toml
./sdk/ruff.toml

$ ruff check .
All checks passed!

$ ruff format --check .
1 file already formatted

$ ruff check --show-files .
/mod/pyproject.toml
/mod/src/generated_ruff_skip/__init__.py

Limits

  • This is standard ruff behavior: ruff still lints a generated file passed explicitly on the command line, unless --force-exclude is set. Pre-commit's ruff hook sets it. With it, ruff format --check --force-exclude sdk/src/dagger/__init__.py reports "No Python files found".
  • Modules generated with an earlier SDK gain three or more ruff.toml files at their next generate. Their generate/stale check reports them once.

Signed-off-by: Yves Brissaud <yves@dagger.io>
Signed-off-by: Yves Brissaud <yves@dagger.io>
@eunomie
eunomie marked this pull request as ready for review November 17, 2026 08:39
@eunomie
eunomie merged commit 3d84461 into main Nov 17, 2026
69 checks passed
@eunomie
eunomie deleted the implementer-fa8b45df branch November 17, 2026 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant